extends Node2D
class_name FloatingText

@onready var value_label: Label = $ValueLabel

func setup(value: String, color: Color) -> void:
    value_label.text = value
    modulate = color
    scale = Vector2.ZERO

    rotation = deg_to_rad(randf_range(-10, 10))
    var random_scale := randf_range(0.8, 1.5)


    var tween := create_tween()

    tween.parallel().tween_property(self, "scale", Vector2(random_scale, random_scale), 0.4)
    tween.parallel().tween_property(self, "global_position", global_position + Vector2.UP * 60, 0.4)
    

    tween.tween_interval(.5)


    tween.parallel().tween_property(self, "scale", Vector2.ZERO, 0.4)
    tween.parallel().tween_property(self, "modulate:a", 0, 0.4)


    await tween.finished

    queue_free()